<!--
 * @Author: hq
 * @Date: 2022-05-26 20:42:41
 * @LastEditors: hq
 * @LastEditTime: 2022-05-26 21:22:37
 * @Description: your project
 * @version: 1.0
-->
<template>
  <div>
    <div class="add">
      <el-input v-model="goodsType" placeholder="请输入商品类别"></el-input>
      <el-button type="primary">添加</el-button>
    </div>
    <el-table
      border
      :data="tableData"
      :header-cell-style="{
        'text-align': 'center',
      }"
      :cell-style="{ 'text-align': 'center' }"
      style="width: 100%"
      highlight-current-row
    >
      <!-- <el-table-column type="selection" min-width="5%"> </el-table-column> -->
      <el-table-column prop="id" label="id" min-width="5%"> </el-table-column>
      <el-table-column prop="type" label="类别" min-width="20%">
      </el-table-column>
      <el-table-column label="操作" min-width="20%">
        <template slot-scope="scope">
          <div class="caozuo">
            <div
              class="handleEdit hand_cs"
              @click="handleEdit(scope.$index, scope.row)"
            >
              修改
            </div>
            <div
              class="handleDelete hand_cs"
              @click="handleDelete(scope.$index, scope.row)"
            >
              删除
            </div>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination">
      <Pagination
        :page="page"
        @onCurrentChange="handleCurrentChange"
        @onSizeChange="handleSizeChange"
      />
    </div>
    <el-dialog
      :close-on-click-modal="false"
      :append-to-body="true"
      title="编辑分类"
      :visible.sync="dialogVisible"
      width="30%"
    >
      <div class="editType">
        <div class="title">编辑分类</div>
        <el-input v-model="editType"></el-input>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import Pagination from "@/components/Pagination.vue";
export default {
  components: { Pagination },
  data() {
    return {
      goodsType: "",
      tableData: [
        {
          id: 1,
          type: "推荐",
        },
        {
          id: 2,
          type: "箱包",
        },
      ],
      dialogVisible: false,
      editType: "",
    };
  },
  methods: {
    handleEdit() {
      this.dialogVisible = true;
    },
    // 每页 ${val} 条
    handleSizeChange(val) {
      //   this.$emit("onSizeChange", val);
    },
    // 当前页: ${val}
    handleCurrentChange(val) {
      //   this.$emit("onCurrentChange", val);
    },
  },
};
</script>

<style lang="scss" scoped>
.add {
  display: flex;
  padding: 0 20px 20px;
  box-sizing: border-box;
  .el-input {
    width: 40%;
  }
  .el-button {
    margin-left: 10px;
  }
}
.caozuo {
  display: flex;
  justify-content: center;
  .handleDelete {
    margin-left: 20px;
  }
}
.editType {
  display: flex;
  align-items: center;
  .title {
    margin-right: 10px;
  }
  .el-input {
    width: 60%;
  }
}
</style>
